#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 5.3.22 9:12 AM
# @File    : login_page.py
from utils.log_manager import Logger
from src.common.base_page import BasePage
from src.suit.weiwenjia.main_page import MainPage


class LoginPage(BasePage):

    def __init__(self, driver):
        super().__init__(driver)
        self.logger = Logger(loggername=self.__class__.__name__).get_logger()

    def account_input(self):
        self.logger.info(u'找到"手机号/邮箱"输入input')
        return self.find_ex_element(selector='i=>account')

    def password_input(self):
        self.logger.info(u'找到"密码"输入input')
        return self.find_ex_element(selector='i=>password')

    def login_btn(self):
        self.logger.info(u'找到"登录"按钮')
        return self.find_ex_element(selector='i=>loginBtn')

    def confim_box(self):
        self.logger.info(u'找到"条款"确认')
        return self.driver.find_elements_by_class_name('ant-checkbox-input')[1]

    def login(self):
        self.logger.info(u'点击"登录"按钮')
        self.confim_box().click()
        self.login_btn().click()
        return MainPage(self.driver)